#include<iostream>
#include<vector>

using namespace std;
int main()
{
    int n;
    cin >> n;

    vector<int> v;
    for (int i = 0; i < n; i++)
    {
        int k = 0;
        cin >> k;
        v.push_back(k);
    }

    int tmp;
    cin >> tmp;

    auto it = v.begin();
    while (it != v.end())
    {
        if (*it == tmp)
        {
            it = v.erase(it);
        }
        else {
            it++;
        }
    }

    cout << v.size() << endl;

    for (auto ch : v)
    {

        cout << ch << " ";
    }
    cout << endl;
    return 0;
}